package com.fxb.learn;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author fangjiaxiaobai
 * @description:
 * @date 2021-11-09 20:05
 */
public class InputStreamEnhanceDemo {
    public static void main(String[] args) throws IOException {
        demo1();
    }

    /**
     * 直接将数据写入输出流
     */
    public static void demo1() throws IOException {
        var classLoader = ClassLoader.getSystemClassLoader();
        var inputStream = classLoader.getResourceAsStream("readFile.txt");
        var javastack = File.createTempFile("writeFile", "txt");
        try (var outputStream = new FileOutputStream(javastack)) {
            inputStream.transferTo(outputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
